Skip to content

fix(studio): locale-correct live addresses; "View live" in editors - #77

Merged
Madraka merged 1 commit into
mainfrom
feat/studio-view-live-locales
Oct 22, 2026
Merged

Madraka merged 1 commit into
mainfrom
feat/studio-view-live-locales

Conversation

@Madraka

@Madraka Madraka commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

A follow-up to #75.

The bug in #75

A page's stored path has no locale prefix: (site, locale, path) is unique, the renderer's localeRequest strips /<locale>, and pageByPath(path, locale) matches on both. #75 used the stored path as the URL, so it showed /hakkinda for a Turkish page served at /tr/hakkinda. It also missed the prefix for every locale under prefix-all routing, and showed only the path for articles in other locales.

Fix

  • core-ts locale-paths.ts (Worker- and browser-safe; @cloudhal/core-ts/locale-paths):
    • localeRouting, localizedPath and localeUrl moved from the renderer, unchanged; the renderer re-exports them.
    • New itemUrl(site, origin, item) for a page or an entry: the graph path (entryPath for entries), then the locale's prefix or its own domain.
  • Studio: the editor addresses, the row "View live"/"Copy link" items, and the live check (live node vs draft, compared by itemUrl) all use it.

"View live" in the editors

A ghost external LinkButton next to the preview toggle in the page and article editor headers, icon-only below lg, with the full URL in the tooltip. It appears only when the live snapshot serves this item at its address, and shares the address query, so there is no extra request.

Bundle headroom

The app-root ShikiProvider pulled Kumo's code.js into the entry chunk and started Shiki on every load. Code blocks now bring their own provider (CodeHighlighted), and bundle-budget.ts guards code.js as lazy-only. Entry gzip: 418.8 → 415.9 kB (budget 420).

Checks (one package at a time)

Package Tests
core-ts 657/657 (new locale-paths.test.ts: prefix-except-default, prefix-all, tr, per-locale domains, /, itemUrl)
astro-renderer 257/257
Studio 1179/1179 (new live-locales.test.tsx: tr page and article addresses, prefix-all, per-locale domain, row links, and "View live" shown or hidden)

Also passing: typecheck, design lint (349 files), and the size ratchet. Screenshots of the article and page editors, Articles and Skills at 1440 and 390 px passed (no sideways scroll or console errors). The local test site is English-only, so localized URLs are covered by tests rather than screenshots.

🤖 Generated with Claude Code

The stored path of a page has no locale prefix (`(site, locale, path)` is
unique; the renderer strips `/<locale>` before the lookup), so #75 showed
`/hakkinda` for a Turkish page served at `/tr/hakkinda`, missed prefixes
under prefix-all routing, and showed only the path for articles in other
locales.

- core-ts `locale-paths.ts` (`@cloudhal/core-ts/locale-paths`):
  `localeRouting`, `localizedPath`, `localeUrl` moved from the renderer
  (which re-exports them, unchanged), plus `itemUrl(site, origin, item)`
  for a page or an entry, with per-locale domains.
- Studio: addresses, row links and the live check use `itemUrl`; a
  "View live" button in the page and article editor headers, shown only
  when the live snapshot serves the item at its address.
- Bundle: the app-root Shiki provider pulled Kumo's code module into the
  entry chunk; code blocks now bring their own (`CodeHighlighted`), and a
  budget guard keeps it lazy. Entry gzip 418.8 → 415.9 kB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
@Madraka
Madraka merged commit 1d3877e into main Oct 22, 2026
5 checks passed
@Madraka
Madraka deleted the feat/studio-view-live-locales branch October 22, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant